
from pyecharts.charts import Bar
from pyecharts import options as opts
# 内置主题类型可查看 pyecharts.globals.ThemeType
from pyecharts.globals import ThemeType

import pandas as pd

xlsx_path = "../data/test01.xls"
df = pd.read_excel(xlsx_path, index_col="用户名称", parse_dates=True)

df = df.head(500)

# 行和列都按区间查询
v1 = df.loc[:, :]


# 不习惯链式调用的开发者依旧可以单独调用方法
bar = Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
bar.add_xaxis(df.index.to_list())
bar.add_yaxis("点赞", df["微博点赞"].to_list())
bar.add_yaxis("评论", df["微博评论量"].to_list())
bar.add_yaxis("转发", df["微博转发量"].to_list())
bar.set_global_opts(title_opts=opts.TitleOpts(title="微博用户影响力", subtitle="个"),datazoom_opts = [
                    opts.DataZoomOpts(orient="horizontal"),
                    opts.DataZoomOpts(orient="vertical"),  # 设置操作图表缩放功能，orient="vertical" 为Y轴
                    opts.DataZoomOpts(type_="inside")  # 设置内部可以滑动功能
                ],
)
bar.render("../data/an_data.html")
